package cn.powerone.scm.mapper;

import java.util.Date;
import java.util.List;
import cn.powerone.scm.domain.ScmSupplierOrders;
import cn.powerone.scm.domain.ScmSupplierOrderItems;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

/**
 * 供应商订单Mapper接口
 * 
 * @author PowerOne
 * @date 2025-07-04
 */
public interface ScmSupplierOrdersMapper 
{
    /**
     * 查询供应商订单
     * 
     * @param id 供应商订单主键
     * @return 供应商订单
     */
    public ScmSupplierOrders selectScmSupplierOrdersById(Long id);

    /**
     * 查询供应商订单列表
     * 
     * @param scmSupplierOrders 供应商订单
     * @return 供应商订单集合
     */
    public List<ScmSupplierOrders> selectScmSupplierOrdersList(ScmSupplierOrders scmSupplierOrders);

    /**
     * 新增供应商订单
     * 
     * @param scmSupplierOrders 供应商订单
     * @return 结果
     */
    public int insertScmSupplierOrders(ScmSupplierOrders scmSupplierOrders);

    /**
     * 修改供应商订单
     * 
     * @param scmSupplierOrders 供应商订单
     * @return 结果
     */
    public int updateScmSupplierOrders(ScmSupplierOrders scmSupplierOrders);

    /**
     * 删除供应商订单
     * 
     * @param id 供应商订单主键
     * @return 结果
     */
    public int deleteScmSupplierOrdersById(Long id);

    /**
     * 批量删除供应商订单
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteScmSupplierOrdersByIds(Long[] ids);

    /**
     * 批量删除供应商订单明细
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteScmSupplierOrderItemsByOrderIds(Long[] ids);
    
    /**
     * 批量新增供应商订单明细
     * 
     * @param scmSupplierOrderItemsList 供应商订单明细列表
     * @return 结果
     */
    public int batchScmSupplierOrderItems(List<ScmSupplierOrderItems> scmSupplierOrderItemsList);
    

    /**
     * 通过供应商订单主键删除供应商订单明细信息
     * 
     * @param id 供应商订单ID
     * @return 结果
     */
    public int deleteScmSupplierOrderItemsByOrderId(Long id);

    @Select("SELECT COUNT(*) FROM scm_supplier_orders WHERE YEAR(create_time) = YEAR(#{yesterday}) AND MONTH(create_time) = MONTH(#{yesterday})")
    @Options(useCache = false, flushCache = Options.FlushCachePolicy.TRUE)
    public int selectSupplierOrderCountByMonth(Date yesterday);

    @Select("SELECT COUNT(*) FROM scm_supplier_orders WHERE YEAR(create_time) = YEAR(#{yesterday})")
    @Options(useCache = false, flushCache = Options.FlushCachePolicy.TRUE)
    public int selectSupplierOrderCountByYear(Date yesterday);

    @Select("SELECT COUNT(*) FROM scm_supplier_orders")
    @Options(useCache = false, flushCache = Options.FlushCachePolicy.TRUE)
    public int selectSupplierOrderCountAll();
}
